<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="oneroom.user.addSeach.addressModel" %>
<jsp:useBean id="areaDao" scope="page" 	class="oneroom.user.area.areaDao" />
<%
	String pageName = "zip_lst.jsp";
	String viewName = "zip_view.jsp";
	int     giSelectPage  	= Integer.parseInt(request.getParameter("txtSelectPage") == null ? "0" :request.getParameter("txtSelectPage"));			//현재 선택된 페이지 저장
	int     giSelectBlock 	= Integer.parseInt(request.getParameter("txtSelectBlock") == null ? "0" :request.getParameter("txtSelectBlock"));			//현재 선택된 블락페이지 저장
	//검색 부분
	String roomkind 	= request.getParameter("roomkind") 	== null ? "" : request.getParameter("roomkind");
	String area 		= request.getParameter("area") 	== null ? "0" : request.getParameter("area");
	String sort 		= request.getParameter("sort") 		== null ? "date" : request.getParameter("sort");
	int     giCount       	= 0;			//리스트 for문 break문에 사용
	int     giRecordcnt   	= 0;			//리스트의 카운터에 사용
	int     giPageSize    	= 10;  			// 한페이지에 나타내고자 하는 List수
	int     giBlockSize   	= 10;   		// Block의 수
	int     giCurPage     	= 1;   			// 현재 Page
	int     giCurBlock    	= 0;   			// 현재 Block
	int     giStartPos    	= 0;   			// 시작 List 위치
	int     giTotPage     	= 0;   			// 총 Page수
	int     giTotBlock    	= 0;   			// 총 Block수
	//  넘겨온 값 받기(List페이지 관련)...
	if ( giSelectPage  >  0 ) { 			// 선택된 Page값이 있을경우....     
		giCurPage  = giSelectPage;   	// 현재Page = 선택된Page 
		giCurBlock = giSelectBlock;  	// 블락page = 선택된 블락 page
	}
	//쿼리를 돌려서 가지고 오는 값
	
	List roomList  = areaDao.getDongRooms( roomkind, 
				area,
				 sort,
				 giSelectPage, 
				 giPageSize);
	if (roomList.size() > 0 ) {
		//전체 게시물 수
		giRecordcnt = areaDao.getDongCount(roomkind, 
											area,
											 sort); 			// 총 list 수
	}
	if (giRecordcnt > 0) {  // 조건에 맞는 값이 있으면....
		giTotPage  = giRecordcnt / giPageSize;
		if (giRecordcnt % giPageSize != 0) {
			giTotPage = giTotPage + 1;			// 총 Page수를 구한다...
		}
		giTotBlock = giTotPage / giBlockSize;
		if (giTotPage % giBlockSize != 0) {
			giTotBlock = giTotBlock + 1;		// 총 Block수를 구한다...
		}
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>원룸몬스터</title>
<link href="/room/css/all.css" rel="stylesheet" type="text/css" />
<script src="/room/script/swfobject_modified.js" type="text/javascript"></script>
<script src="/room/script/common.js" type="text/javascript"></script>
<script src="/room/script/jquery-1.3.2.min.js" type="text/javascript" ></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
	$('#zipcode2').change(function() {//AJAX로 주소 가지고옴 시 구를 가지고옴 
		$.ajax({type : "post",
			url : "/room/zip/zipcode.jsp",
			dataType : "html",
			data : "zip_code2="+document.getElementById("zipcode2").value,
			success : function(msg){
				document.getElementById("zip3").innerHTML = msg;
			}
		});
	});
	$('#seach').click(function() {
		document.getElementById("frm").submit();
	});
	$('#datesort').click(function() {
		document.getElementById("sort").value="date";
		document.getElementById("frm").submit();
	});
	$('#depositsort').click(function() {
		document.getElementById("sort").value="deposit";
		document.getElementById("frm").submit();
	});
	$('#monthsort').click(function() {
		document.getElementById("sort").value="month";
		document.getElementById("frm").submit();
	});
	$('#re').click(function() {
		location.href="zip_lst.jsp";
	});

});

function zipCode3(){
	//$('#zipcode3').change(function() {//AJAX로 주소 가지고옴 읍면동을 가지고옴
		$.ajax({type : "post",
			url : "/room/zip/zipdong.jsp",
			dataType : "html",
			data : "zip_code3="+document.getElementById("zipcode3").value,
			success : function(msg){
				document.getElementById("zipdong").innerHTML = msg;
			}
		});
	//});
}

function goView(oneroomseq){
	document.frmView.oneroom_seq.value = oneroomseq;
	document.frmView.submit();
}
//-->
</script>

</head>

<body>
<div align="center"> 

 <div id="content">

<!----------------왼쪽---------------->  
  <%@ include file="/room/common/left.jsp" %> 
<!----------------왼쪽끝---------------->  


<!----------------가운데 시작----------------> 
 <div id="rgt">
  <div id="con01">
   <div class="top bb1"><img src="/room/img/txt_top.gif" /></div>
   
   <div class="map1">
     <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="625" height="381">
       <param name="movie" value="/room/fla/map01.swf" />
       <param name="quality" value="high" />
       <param name="wmode" value="opaque" />
       <param name="swfversion" value="6.0.65.0" />
       <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
       <param name="expressinstall" value="Scripts/expressInstall.swf" />
       <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
       <!--[if !IE]>-->
       <object type="application/x-shockwave-flash" data="/room/fla/map01.swf" width="625" height="381">
         <!--<![endif]-->
         <param name="quality" value="high" />
         <param name="wmode" value="opaque" />
         <param name="swfversion" value="6.0.65.0" />
         <param name="expressinstall" value="Scripts/expressInstall.swf" />
         <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
         <div>
           <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
           <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
         </div>
         <!--[if !IE]>-->
       </object>
       <!--<![endif]-->
     </object>
   </div>
 
<!------------------리스트 시작---------------------->  
 <div class="pt15 pl10" style="width:600px">
  <!--탭-->
   <div>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <col width="77px" /> <col width="77px" /> <col width="77px" /> <col width="370px" />
    <tr>
     <td><img src="/room/img/tab_01<%if(sort.equals("date")){out.print("_on");} %>.gif" id="datesort" onmouseover="MM_swapImage('datesort','','/room/img/tab_01_on.gif',1)" onmouseout="MM_swapImgRestore()"/></td>
     <td><img src="/room/img/tab_02<%if(sort.equals("deposit")){out.print("_on");} %>.gif" id="depositsort" onmouseover="MM_swapImage('depositsort','','/room/img/tab_02_on.gif',1)" onmouseout="MM_swapImgRestore()"/></td>
     <td><img src="/room/img/tab_03<%if(sort.equals("month")){out.print("_on");} %>.gif" id="monthsort" onmouseover="MM_swapImage('monthsort','','/room/img/tab_03_on.gif',1)" onmouseout="MM_swapImgRestore()"/></td>
     <td class="bb2">&nbsp;</td>
   </tr>
  </table>
  </div>
 <!--탭끝-->
 <%
		if(roomList != null && roomList.size() > 0){
			giCount  = 1;
			giRecordcnt = giRecordcnt - ( giCurPage -1 ) * giPageSize;	
			giStartPos = ((giCurPage - 1) * giPageSize) + 1;
	%>
	<%for(int i=0; i<roomList.size(); i++){ %>
	<% addressModel model = (addressModel)roomList.get(i);%>
 <div class="pt10 pb10 bb1">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <col width="109px;" />
   <col width="329px;" />
   <col width="100px;" />
   <col width="62px;" />
   
  <tr>
    <td class="thum01"><a href="javascript:goView('<%=model.getOneroom_seq()%>')"><%if(model.getPhoto1_main().equals("1")){ %>
			<img src="/download/<%=model.getPhoto1_small() %>?name=<%=model.getPhoto1_small() %>&kind=img" />
		<%}else if(model.getPhoto1_main().equals("2")){ %>
			<img src="/download/<%=model.getPhoto2_small() %>?name=<%=model.getPhoto2_small() %>&kind=img" />
		<%}else if(model.getPhoto1_main().equals("3")){ %>
			<img src="/download/<%=model.getPhoto3_small() %>?name=<%=model.getPhoto3_small() %>&kind=img" />
		<%}else if(model.getPhoto1_main().equals("4")){ %>
			<img src="/download/<%=model.getPhoto4_small() %>?name=<%=model.getPhoto4_small() %>&kind=img" />
		<%}else if(model.getPhoto1_main().equals("5")){ %>
			<img src="/download/<%=model.getPhoto5_small() %>?name=<%=model.getPhoto5_small() %>&kind=img" />
		<%}else if(model.getPhoto1_main().equals("6")){ %>
			<img src="/download/<%=model.getPhoto6_small() %>?name=<%=model.getPhoto6_small() %>&kind=img" />
		<%} %></a></td>
    <td valign="top" class="pt5 pl10"><span class="fw"><%=model.getTitle() %></span>~<br /><%=model.getContent() %>
    </td>
    <td valign="top" class="pt5 fw">전세<span class="c_org fs11"> <%=model.getRoommoney() %></span><br />
월세 <span class="c_org fs11"> <%=model.getRoommonth1() %>/<%=model.getRoommonth2() %></span> </td>
    <td valign="top" class="pt5"><%=model.getCreatedate() %></td>
  </tr>
</table>
</div>

<%
		giCount = giCount + 1;
		giRecordcnt = giRecordcnt - 1;
	%>
	<%} %>
	<%}else{ %>
<div class="pt10 pb10 bb1">
	  <table width="100%" border="0" cellspacing="0" cellpadding="0">
	   <col width="100%" />
	  <tr>
	  	<td>
	  		검색된 매물 정보가 없습니다.
	  	</td>
	  </tr>
	</table>
</div>

	<%} %>
<!------------------리스트 끝---------------------->  
</div>
  </div>  
<!----------------가운데 끝---------------->



<!----------------오른쪽 시작---------------->    
   <%@ include file="/room/common/right.jsp" %>
<!----------------오른쪽 끝---------------->
</div>


<!-------------푸터영역----------> 
<%@ include file="/room/common/footer.jsp" %> 

<map name="Map_tmore" id="Map"><area shape="rect" coords="178,0,200,15" href="#" /></map>
<script type="text/javascript">
swfobject.registerObject("FlashID");
</script>
<form action="area_view.jsp" method="post" id="frmView" name="frmView">
<input type="hidden" name="roomkind"  value="<%=roomkind%>"/>
<input type="hidden" name="area" id="area" value="<%=area %>" />
<input type="hidden" name="oneroom_seq" id="oneroom_seq" />
</form>
</body>
</html>
